import Vue from 'vue'
import VueRouter from 'vue-router'
/* 无论使用与否，都加载一个组件 */
import HomeView from '../views/HomeView.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'home',
    component: HomeView
  },
  {
    path: '/about',
    name: 'about',
    /* 只有在访问到该页面时才进行组件加载 */
    component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
  },
  {
    path: '/teacher',
    name: 'teacher',
    component: () => import('@/views/TeacherView.vue')
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
